Thread: Probably a pathetic lil error but i dont seem to find it |:<

  1. #1
    Registered User
    Join Date
    Nov 2018
    Posts
    11

    Probably a pathetic lil error but i dont seem to find it |:<

    sorry if this seems trivial, but ima beginner, its not really about the Text (its in German due to me studying there )
    The "program" is should calculate the surface area, the extend and the diagonal line.
    Somehow its not calculating my operations, and just outputs 0's
    I dont quiet know what's wrong :|


    Code:
    #include <stdio.h>
    #include <math.h>
    
    
    
    
    int main()
    
    
    {
        
        double h, b, diagonale, umfang, flaeche;
        do
        {
        umfang = 0;
        flaeche = 0;
        diagonale = 0;
        
            
        printf("\nGeben sie die Seitenlängen eines Rechtecks an (HxB)\n");
        scanf("%lf %lf",&h, &b);
        
        // Berechnung und Ausgabe der Diagonalen
        sqrt(pow(h,2) + pow(b,2)) == diagonale;
        printf("\nDie Diagonale des eingegebenen Rechtecks ist %lf\n", diagonale);
        
        // Berechnung und Ausgabe von Umfang
        printf("\nDer Umfang des eingegebenen Rechtecks ist %lf\n", 2*h+2*b=umfang);
        
        // Berechnung und Ausgabe von der Fäche
        h*b == flaeche;
        printf("\nDie Fläche des eingegebenen Rechtecks ist %lf\n", flaeche);
        
        }
        while (h,b >= 0);
        
        return 0;
        
    }
    Thanks for reading and maybe helping me out!

  2. #2
    Registered User
    Join Date
    Jun 2017
    Posts
    157
    One problem is on line 24: == is the comparison operator, but you should assign it to the var diagonale.
    diagonale = sqrt(pow(h,2) + pow(b,2));

    Same problem on line 31

    How did you manage to compile this code ?
    You should get an error msg like this:
    main.c:28:72: error: lvalue required as left operand of assignment

  3. #3
    Registered User
    Join Date
    Nov 2018
    Posts
    11
    this helped alot, still
    "error: lvalue required as left operand of assignment
    h*b=flaeche;"
    ^
    when my code looks like this

    Code:
    h*b=flaeche;
        printf("\nDie Fläche des eingegebenen Rechtecks ist %lf\n",flaeche);

  4. #4
    Registered User
    Join Date
    Nov 2018
    Posts
    11
    (the ^ is below the "=" )

  5. #5
    Registered User
    Join Date
    Jun 2017
    Posts
    157
    Imagine h == 2 and b == 3. Does 6 = flaeche make any sense?

    Doesn't your textbook tell you how to assign values to a variable ?

  6. #6
    Registered User
    Join Date
    May 2015
    Posts
    56
    Code:
    h*b=flaeche;
        printf("\nDie Fläche des eingegebenen Rechtecks ist %lf\n",flaeche);
    
    should be
    flaeche = h*b;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Only run if dont find a process
    By tom1 in forum C++ Programming
    Replies: 22
    Last Post: 03-09-2010, 06:27 AM
  2. Someone help my pathetic excuse for GUI coding
    By bikr692002 in forum Windows Programming
    Replies: 2
    Last Post: 04-10-2006, 05:42 PM
  3. Criminal pirate amateur idiotic pathetic
    By adrianxw in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 11-28-2002, 03:58 PM
  4. Why do you think ppl think programmers conversations are the most pathetic ones???
    By Null Shinji in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-25-2001, 08:10 AM
  5. Replies: 3
    Last Post: 10-01-2001, 12:17 PM

Tags for this Thread